<div ng-controller="EntryCommentController">
    <div class="row pad_top">
        <div class="col-md-12">
            <button type="button" data-ng-click="addComment=true" class="ice-button">
                <i style="font-size: 14px; color: #007dbc" class="fa fa-comment"></i> Add Comment
            </button>

            <div class="pad-top-5" data-ng-show="addComment" style="margin-left: 50px">
                <form name="createCommentForm" data-ng-submit="createComment()" class="entry-form">
                    <textarea class="input_box" data-ng-model="newComment.message" placeholder="Enter comment" rows="6"
                              cols="70"></textarea>

                    <div ng-if="entrySamples" style="vertical-align: top; padding-bottom: 15px">
                        <b class="font-90em">Affected Samples</b><br>
                        <label class="checkbox-inline font-90em" ng-repeat="sample in entrySamples">
                            <input type="checkbox" ng-click="addRemoveSample(sample)">{{sample.label}}
                        </label>
                    </div>
                    <div>
                        <button type="submit" class="btn btn-primary btn-sm">Submit</button>
                        <button type="button" data-ng-click="addComment=false" class="btn btn-default btn-sm">Cancel
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="row pad_top" ng-if="entryComments.length===0">
        <div class="col-md-12">
            <i class="text-muted">No comments available</i>
        </div>
    </div>

    <div class="row" ng-if="entryComments.length > 0">
        <div class="col-md-12">
            <div class="comment margin-top-20" ng-repeat="comment in (comments = (entryComments | orderBy: 'id':true))">
                <span class="close pull-left">{{entryComments.length - $index}}</span>
                <small class="attachment_small_text pull-right">{{comment.commentDate | date:'medium'}}</small>
                <br><br>

                <div ng-if="!comment.edit">{{comment.message}}
                    <div ng-if="comment.samples != null && comment.samples.length">
                        <br><b style="color: #a52a2a">Affected Samples</b>

                        <div ng-repeat="sample in (samples = (comment.samples | orderBy: 'id':true))">
                            &nbsp; &nbsp;<i class="fa fa-flask"></i> {{sample.label}}
                        </div>
                    </div>
                </div>
                <div ng-if="comment.edit"><textarea rows="5" cols="60" class="input_box"
                                                    ng-model="comment.message"></textarea>

                    <div>
                        <button type="submit" class="btn btn-primary btn-xs" ng-click="updateComment(comment)">Update
                        </button>
                        <button type="button" ng-click="comment.edit=false" class="btn btn-default btn-xs">Cancel
                        </button>
                    </div>
                </div>
                <br><br>

                <div style="height: 1px; margin: 9px 0; overflow: hidden; background-color: #e5e5e5"></div>
                <div class="pull-left"><a ng-href="profile/{{comment.accountTransfer.id}}">{{comment.accountTransfer.firstName}}
                    {{comment.accountTransfer.lastName}}</a> &nbsp; <i ng-if="comment.modified" class="small opacity_4">Last
                    edited on {{comment.modified | date: 'short'}}</i></div>
                <span ng-if="user.email===comment.accountTransfer.email||user.isAdmin"></span>

                <div class="pull-right" ng-click="comment.edit=true"><i class="fa fa-edit edit_icon"></i>
                </div>
            </div>
        </div>
    </div>
</div>

